<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/3/7
 * Time: 14:33
 */

namespace app\models;


use yii\data\Pagination;
use yii\db\ActiveRecord;

class Country extends ActiveRecord
{
    public function getAll()
    {
        $query = self::find();
        $pagination = new Pagination(['defaultPageSize' => '5', 'totalCount' => $query->count()]);
        $datas['countries'] = $query->orderBy('name')->offset($pagination->offset)->limit($pagination->limit)->all();
        $datas['pagination'] = $pagination;
        return $datas;
    }
}